import { ApiCall, WsConnection } from "tsrpc";
import { ReqStopTalk, ResStopTalk } from "../../../shared/protocols/AMessages/Live/PtlStopTalk";
import { Live } from '../../../utils/Classes/Live';
import { Wsserver } from "../../..";

export default async function (call: ApiCall<ReqStopTalk, ResStopTalk>) {
    // TODO
    const student = call.currentUser
    const live = Live.lives.find(live => live.courseId.equals(call.req.course))
    if(!live) return call.error('不存在');

    //all numbers
    const connections = new Array<WsConnection>()
    live.students.forEach(s =>{
        if(s.connection){
            connections.push(s.connection)
        }
    })
    connections.push(live.host.connection)

    Wsserver.broadcastMsg('AMessages/Live/SBTalk',{
        studentId:'',
        studentName:''
    },connections)

    call.succ({

    })
}